<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>获取表单控件的设置值</title>

<link rel="stylesheet" type="text/css" href="css/mobile.css" />
<link rel="stylesheet" type="text/css" href="css/public.css" />
<script type="text/javascript" >
function id(name){
  return document.getElementById(name);};
function tag(name,elem){ 
  return (elem||document).getElementsByName(name);}

function isNumeric(fData){
  if (isEmpty(fData))
	  return true
  if (isNaN(fData))
	  return false
  return true    
}

function isEmpty(fData){
  return ((fData==null) || (fData.length==0))
}

// 取得单选按钮组的值
function getRadValue(strRadName){
  var objRad = tag(strRadName);
  var strReturn = "";
  for (var i=0;i<objRad.length;i++){
	  if (objRad[i].checked==true){
		  strReturn = objRad[i].value;
		  break;
	  };
  };
  return strReturn;
};
//取得复选框的值
function getChkBoxValue(strRadName){
  var objChkBox = tag(strRadName);
  var strReturn = "";
  for (var i=0;i<objChkBox.length;i++){
	if (objChkBox[i].checked==true){
		if (strReturn!="") strReturn += ",";
		strReturn += objChkBox[i].value;
	};
  };
  return strReturn;
};

//提交搜索表单
function goFSch(){
  id("phoneFace").value = getRadValue("radPhoneFace");
  id("phoneFun").value = getChkBoxValue("chkPhoneFun");
  id("hidForm").submit();
};

function goPSch(strBeginPrice,strEndPrice){
  var strPriceRange = "";
  if (isNumeric(strBeginPrice) && isNumeric(strEndPrice)){
	  strPriceRange = strBeginPrice + "->" + strEndPrice;
  } else if (isNumeric(strBeginPrice)){
	  strPriceRange = strBeginPrice + "->0";
  } else if (isNumeric(strEndPrice)){
	  strPriceRange = "0->" + strEndPrice;
  };
  id("priceRange").value = strPriceRange;
  id("hidForm").submit();
};

function goPSchB(){
  var strPriceRange = "";
  var strBeginPrice = id("beginPrice").value;
  var strEndPrice = id("endPrice").value;
  //-------------------------------------------------
  if (!isNumeric(strBeginPrice)){
	  alert("价格区间只能输入数字！");
	  id("beginPrice").focus();
	  return false;
  };
  if (!isNumeric(strEndPrice)){
	  alert("价格区间只能输入数字！");
	  id("endPrice").focus();
	  return false;
  };
  //-------------------------------------------------
  if (strBeginPrice!="" && strEndPrice!=""){
	  strPriceRange = strBeginPrice + "->" + strEndPrice;
  } else if (strBeginPrice!=""){
	  strPriceRange = strBeginPrice + "->0";
  } else if (strEndPrice!=""){
	  strPriceRange = "0->" + strEndPrice;
  } else {
	  return false;
  }
  //-------------------------------------------------
  id("priceRange").value = strPriceRange;
  id("hidForm").submit();
};
</script>


</head>

<body>
<div class="fullCell">
<div class="lft">
  <div class="pSearch mt_10px">
    <div class="tit">
      <h3>手机价格搜索</h3>
    </div>
    <div class="con">
      <ul>
        <li class="l"><a href="javascript:goPSch(0,800);">&yen;800以下</a></li>
        <li class="r"><a href="javascript:goPSch(800,1500);">&yen;800-1500</a></li>
      </ul>
      <ul>
        <li class="l"><a href="javascript:goPSch(1500,3000);">&yen;1500-3000</a></li>
        <li class="r"><a href="javascript:goPSch(3000,0);">&yen;3000以上</a></li>
      </ul>
      <dl>
        <dt>&yen;</dt>
        <dd>
          <input type="text" class="sInput" value="" id="beginPrice" name="beginPrice" />
        </dd>
        <dt> — &yen;</dt>
        <dd>
          <input type="text" class="sInput" value="" id="endPrice" name="endPrice" />
        </dd>
      </dl>
      <h4>
        <input type="button" value="" class="btn" id="button1" onclick="goPSchB();" />
      </h4>
    </div>
  </div>
  
  <div class="fSearch mt_10px">
      <div class="tit">
          <h3>手机功能搜索</h3>
      </div>
      <div class="con">
          <h3>外观</h3>
          <ul>
              <li class="l"><input type="radio" name="radPhoneFace" value="ZhiBan" />直板</li>
              <li class="r"><input type="radio" name="radPhoneFace" value="ZheDie" />折叠</li>
          </ul>
          <ul>
              <li class="l"><input type="radio" name="radPhoneFace" value="HuaGai" />滑盖</li>
              <li class="r"><input type="radio" name="radPhoneFace" value="XuanZhuan" />旋转</li>
          </ul>
          <ol><li class="dotline"></li></ol>
          <h3>功能</h3>
          <ul>
              <li class="l"><input type="checkbox" name="chkPhoneFun" value="ifMp3"/>MP3</li>
              <li class="r"><input type="checkbox" name="chkPhoneFun" value="ifMp4"/>MP4</li>
          </ul>
          <ul>
              <li class="l"><input type="checkbox" name="chkPhoneFun" value="ifFM"/>FM</li>
              <li class="r"><input type="checkbox" name="chkPhoneFun" value="Bluetooth"/>蓝牙</li>
          </ul>
          <ol><li class="dotline"></li></ol>
          <h4><input type="button" value="" class="btn" id="btn" onclick="goFSch();" /></h4>
    </div>
  </div>
</div>
</div>

<form id="hidForm" name="hidForm" action="" method="get">
  <input id="phoneFace" name="phoneFace" type="hidden" value="" />
  <input id="phoneFun" name="phoneFun" type="hidden" value="" />
  <input id="priceRange" name="priceRange" type="hidden" value="" />
</form>
</body>

</html>
